package org.gwtEss.other;

import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class DivPanel extends SimplePanel {

	public DivPanel() {
		super();
	}
	@Override
	public void setWidget(Widget w) {
		if (super.getWidget() == null)
			getElement().setInnerHTML("");//TODO need a better way to remove text if any
		super.setWidget(w);
	}
	public DivPanel(Widget w) {
		super();
		super.setWidget(w);
	}

	public DivPanel(String txt) {
		super();
		super.getElement().setInnerHTML(txt);
	}

	public void setText(String text) {
		Widget w = super.getWidget();
		if (w != null)
			super.remove(w);
		super.getElement().setInnerHTML(text);
	}

	public String getText(){
		if (super.getWidget() != null)
			return null; 
		return super.getElement().getInnerHTML();
	}
}
